﻿#region summary
// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.
#endregion

using System;

namespace NSQL
{
    public class TableSource : ITableSource
    {
        /// <inheritdoc />
        public string Alias { get; set; }
        public string Name { get; set; }
        public string Schema { get; set; }
        public TableSource(string name, string schema = null)
        {
            Name = name;
            Schema = schema;
        }

        public static implicit operator TableSource(string name) => new TableSource(name);

        /// <inheritdoc />
        public JoinNode Join { get; set; }

        public bool IsDual => Schema == null && Alias == null &&
                              string.Equals("dual", Name, StringComparison.OrdinalIgnoreCase);

        public object Tag { get; set; }
    }
}